from django.shortcuts import render, HttpResponse
from .models import Student


# Create your views here.


def add_student(request):
    import datetime
    # 1.save方法
    # stu = Student(name='Tom', age=20, gender=1, birthday=datetime.date(2000, 1, 1))
    # stu.save()
    # 2.create方法
    stu =Student.objects.create(name='杜建基', age=24, gender=1, birthday=datetime.date(2001, 1, 1))
    return HttpResponse('Add student successfully!')

def select_student(request):
    stu_list = Student.objects.all()
    print(stu_list.values('name','age')[0]['name'])
    return HttpResponse('查询学生成功！')